﻿//-----------------------------------------------------------------------
// <copyright file="SA1009.cs" company="c0x3y">
//     Copyright (c) c0x3y. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace c0x3y.StyleCopFixer.Errors
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Text.RegularExpressions;
    using EnvDTE;
    using EnvDTE80;

    public static class SA1009
    {
        public static void Run(EnvDTE.DTE environment, ErrorItem selectedError)
        {
            if (selectedError == null)
            {
                throw new ArgumentNullException("selectedError", "Selected error is null");
            }

            selectedError.Navigate();

            //Replace all items that have spaces between the ending brackets
            ErrorUtilities.RegExUpdateWholeDocument(@"\)\s+\)", "))", selectedError, environment);
            
            // replace all items that have a cariage return between each line
            ErrorUtilities.RegExUpdateWholeDocument(@"(\s+[a-zA-Z]+\))\s*\r\n(\).*)", "$1$2", selectedError, environment);                        
        }
    }
}
